package com.uyaer.engine.display.el
{
	import com.uyaer.engine.utils.HashMap;
	
	import flash.display.BitmapData;
	import flash.geom.Rectangle;
	
	public class Animation extends BitmapAnimation
	{
		private static var map:HashMap = new HashMap();
		private var id:String;
		private var _isShare:Boolean = true;
		public function Animation(id:String, bmData:BitmapData, frames:Vector.<Rectangle>)
		{
			this.id = id;
			if(!map.hasKey(id)){
				this.cache = bmData;
				_isShare = false;
			}
			super(cache, frames);
		}
		
		override protected function init():void
		{
			if(isShare){
				this.bitmapData = map.get(id) as BitmapData;
			}else{
				super.init();
				map.put(id,this.bitmap);
			}
		}

		public function get isShare():Boolean
		{
			return _isShare;
		}

	}
}